package com.thinkfit.jy.utils;

import android.content.Context;

import com.thinkfit.jy.serialport.SerialPortManager;
import com.thinkfit.jy.view.RightSpeedSetView;
import com.thinkfit.jy.view.LeftSlopSetView;

public class ShowSpeeldAndSlopUtils {

    private static ShowSpeeldAndSlopUtils showSpeeldAndSlopUtils;

    public static ShowSpeeldAndSlopUtils getInstance(){
        if(showSpeeldAndSlopUtils == null){
            showSpeeldAndSlopUtils = new ShowSpeeldAndSlopUtils();
        }
        return showSpeeldAndSlopUtils;
    }

    public void showView(Context context,boolean isShowLeft,boolean isShowRight){
        if(isShowRight){
            RightSpeedSetView.getInstance().initView(context);
        }
        if(isShowLeft){
            LeftSlopSetView.getInstance().initView(context);
        }

    }


    public void setInfo(SerialPortManager.CurrentInfo info){
        if(info != null){
            String speed = "";
            if(MotionDataUtils.mCurrentDeviceType.equals(DeviceTypeUtils.TREADMILL)){
                speed = Utils.getNewFloat(info.speed / 10f);
            }else {
                speed = Utils.getNewFloat(info.speed / 100f);
            }
            System.out.println("aaaaaaaaaaaaaaaaaaaaaa    info.slop : "+info.slop);
//            RightSpeedSetView.getInstance().setSpeedInt(speed);
//            LeftSlopSetView.getInstance().setSlopInt(String.valueOf(info.slop));
        }
    }

//    public void stopInitView(){
//        RightSpeedSetView.getInstance().setSpeedInt("0");
//        LeftSlopSetView.getInstance().setSlopInt(String.valueOf(0));
//    }

    /**
     * 显示左右两边的调节控件
     * @param context
     */
    public void showAllView(Context context){
        showView(context,true,true);

    }

    /**
     * 只显示左边的
     * @param context
     */
    public void showLeft(Context context){
        showView(context,true,false);
    }

    /**
     * 只显示右边的
     * @param context
     */
    public void showRight(Context context){
        showView(context,false,true);
    }


    /**
     * 隐藏
     */
    public void goneView(){
        RightSpeedSetView.getInstance().goneLayout();
        LeftSlopSetView.getInstance().goneLayout();
    }

}
